<template>
  <!-- v-loading="true" -->
  <div class="pb-[10px]">
    <div class="flex items-center pt-[20px] px-[20px]">
      <div class="text-[24px] font-semibold ">管理员账号</div>
      <div @click="$router.push('/account')" class="ml-auto cursor-pointer" style="color: #6B7988;">全部管理员&nbsp;&nbsp;>
      </div>
    </div>
    <pageTable :tableData="tableData" :tableInit="params.tableInit" v-loading="loading">
      <template #operation="{ row }">
        <el-button type="primary" link @click="tapOperation(row)">编辑</el-button>
        <template v-if="row.sysUserId != 1">
          <el-popconfirm title="确认要删除吗?" @confirm="delData(row.sysUserId)">
            <template #reference>
              <el-button type="danger" link>删除</el-button>
            </template>
          </el-popconfirm>
        </template>
      </template>



    </pageTable>







  </div>
</template>

<script setup lang="ts">
import pageTable from "@/components/base-ui/page-table";
import { getSelpage, delinfo, updateauth } from "@/api/home"
import { tableInit } from "./config/administrators.config";
import { usepageTable } from '@/components/base-ui/page-table/usePageTable'
import { clone } from "@pureadmin/utils";
import { message } from "@/utils/message";

const emit = defineEmits(["compile"]);

const {
  tableData,
  getData,
  params,
  loading,
  DrawerSubmit,
  delData,
  operateObj,
  DrawerType

} = usepageTable({
  tableInit,
  getRes: getSelpage,
  delRes: delinfo,
  updateRes: updateauth,
  updateResCallBack: () => {
    getData()
    message("修改成功", {
      type: "success"
    });
  }
})

getData()


const tapOperation = (row) => {
  DrawerType.value = '编辑'
  operateObj.value = clone(row, true);
  emit('compile', row)
}

defineExpose({
  DrawerSubmit,
  getData,
});

</script>

<style scoped></style>
